<?php

require('conn.cfg.php');    
require('functions.php');    

$redirectSurvey = true;
	
if (isset($_POST['inf_field_Email'])) {
    $contact = $_POST['inf_field_Email'];
	
	if (!isValidEmail($contact)){
		 header( 'Location: http://x2performance.wdgcorp.com/index.html' ) ;
	}

	if(isTrialExist($contact)){
		$redirectSurvey = false;
	}
	
    if($redirectSurvey)
    {
	$_SESSION['trail_email'] = $contact; // save to session	
        //saveTrialUser($contact);
       ?>
	   <form action="trial.php" method='post' name='frm'>
<?php
	echo "<input type='hidden' name='email' value='".$_POST['inf_field_Email']."'>";
?>
	</form>
<script language="JavaScript">
	document.frm.submit();
</script>
 <?php
    }
    else
    {
           header( 'Location: http://x2performance.wdgcorp.com/reject_trial.html' ) ;
    }
} else {
    header( 'Location: http://x2performance.wdgcorp.com/index.html' ) ;
}
?>